#include("../../comm/ListHead.html")
<div class="layui-fluid layui-anim layui-anim-fadein">
    <div class="layui-card">
        <div class="card-search SearchTable">
            <p style="float:right">
                #(form.select.status)
                <label class="table-search-title">UID</label>
                <input type="text" id="uid" lay-verify="required" placeholder="" autocomplete="off"
                       class="table-search-text width80">
                <label class="table-search-title">批次</label>
                <input type="text" id="keyid" lay-verify="required" placeholder="" autocomplete="off"
                       class="table-search-text width120">
                <button class="layui-btn layui-btn-warm layui-btn-sm" lay-event="DoSearch">
                    搜索
                </button>
            </p>
            <div class="layui-tab layui-tab-brief">
                <ul class="layui-tab-title" style="width: 300px;float:left">
                    <li class="layui-this">消息发送</li>
                    <li lay-event="TurnTempletList">模板管理</li>
                </ul>
            </div>
        </div>
        <div class="layui-card-body">
            <table class="layui-hide" id="table_1" lay-filter="table_1"></table>

            <script type="text/html" id="table_1_bar_title">
                <div class="layui-btn-container">
                    <button class="layui-btn layui-btn-sm" lay-event="SendMessage" permission-one="btn-del">重新发送</button>
                </div>
            </script>
        </div>
    </div>
</div>
<script language="JavaScript">
    layui.use(['table', 'form', 'myTable', 'myTool'], function () {
        table = layui.table, myTool = layui.myTool, myTable = layui.myTable;
        tableindex = layui.myTable.render({
            elem: '#table_1', skin: 'line'
            , height: 'full-86'
            , url: 'WxMessageListDataApi'
            , toolbar: '#table_1_bar_title'
            , title: '消息发送列表'
            , cols: [[
                {type: 'checkbox', width: 36}
                , {field: 'msg_id', title: 'ID', width: 70, align: 'center'}
                , {field: 'mem_id', title: 'UID', align: 'left', width: 80}
                , {field: 'key_id', title: '批次', align: 'left', width: 100}
                , {field: 'msg_first', title: '提醒信息', align: 'left', width: 280}
                , {field: 'create_date', title: '创建时间', align: 'left', width: 160}
                , {field: 'status_str', title: '状态', align: 'center', width: 90}
                , {field: 'send_date', title: '发送时间', align: 'left', width: 160}
                , {field: 'send_desc', title: '备注', hide: false}
            ]]
            , page: true
            , limit: 10
            , editField: {url: 'ModifyWxMessageFieldApi', key: 'ids'}
        });

        layui.util.event("lay-event", {
            DoSearch: function () {
                tableindex.reload({
                    where: {s: {status: $("#status").val(), keyid: $("#keyid").val(), uid: $("#uid").val()}}
                    , page: {curr: 1}
                });
            }
            , TurnTempletList: function () {
                window.location.href = "WxTempletList";
            }
        });

        table.on('toolbar(table_1)', function (obj) {
            myTool.toolbar(this, obj, {
                SendMessage: function () {
                    myTool.doSingleSelect(myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = layer.confirm('你是否确认重发至【' + data[0].u_id + '】', {icon: 3, title: '提示', offset: '100px'}, function (index2) {
                            layui.myTool.post("SendMessageApi", {ids: data[0].ids}, function () {
                                layer.closeAll();
                            });
                        });
                    });
                }
            });
        });
    });
</script>
</body>
</html>